//
//  MCMineAddBankCardViewController.m
//  TLYL
//
//  Created by miaocai on 2017/7/12.
//  Copyright © 2017年 TLYL01. All rights reserved.
//

#import "MCMineAddBankCardViewController.h"
#import "MCButton.h"

@interface MCMineAddBankCardViewController ()
@property (nonatomic,weak) UIButton *addBtn;
@property (nonatomic,weak) UIScrollView *baseScrollView;
@property (nonatomic,weak) UITextField *nameTF;
@end

@implementation MCMineAddBankCardViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationItem.title = @"添加银行卡";
    [self setUpUI];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(showkeyBoard:) name:UIKeyboardWillShowNotification object:nil];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(hidekeyBoard:) name:UIKeyboardWillHideNotification object:nil];
}
- (void)showkeyBoard:(NSNotification *)noti{
    NSDictionary *dic = noti.userInfo;
    CGRect rect = [dic[@"UIKeyboardBoundsUserInfoKey"] CGRectValue];

    [UIView animateWithDuration:0.25 animations:^{
        self.baseScrollView.contentSize = CGSizeMake(0, G_SCREENHEIGHT - CGRectGetMaxY(self.addBtn.frame) - rect.size.height);
        self.baseScrollView.contentOffset = CGPointMake(0, G_SCREENHEIGHT - CGRectGetMaxY(self.addBtn.frame) - rect.size.height);
        
    }];
}
- (void)hidekeyBoard:(NSNotification *)noti{
    [UIView animateWithDuration:0.25 animations:^{
        self.baseScrollView.contentSize = CGSizeMake(0, -64);
        self.baseScrollView.contentOffset = CGPointMake(0, -64);
        
    }];
}
- (void)setUpUI{
    UIScrollView *baseScrollView = [[UIScrollView alloc] init];
    [self.view addSubview:baseScrollView];
    self.baseScrollView = baseScrollView;
    UIView *bgViewName = [[UIView alloc] init];
    [baseScrollView addSubview:bgViewName];
    bgViewName.backgroundColor = [UIColor whiteColor];
    self.view.backgroundColor = RGB(238, 246, 252);
    UILabel *nameLabel = [[UILabel alloc] init];
    [bgViewName addSubview:nameLabel];
    nameLabel.text = @"姓名";
    nameLabel.textColor = MC_SKYBLUE_COLOR;
    nameLabel.font = [UIFont systemFontOfSize:MC_REALVALUE(14)];
    UITextField *nameTf = [[UITextField alloc] init];
    nameTf.attributedPlaceholder = [[NSAttributedString alloc] initWithString:@"请输入持卡人姓名" attributes:@{NSForegroundColorAttributeName : [UIColor colorWithHexString:@"#b1b1b1"],NSFontAttributeName : [UIFont systemFontOfSize:MC_REALVALUE(14)]}];
    [bgViewName addSubview:nameTf];
    UIView *lineView1 = [[UIView alloc] init];
    lineView1.backgroundColor = MC_SEPAETOR_COLOR;
    [baseScrollView addSubview:lineView1];
    self.nameTF = nameTf;
    
    UIView *bgViewName1 = [[UIView alloc] init];
    [baseScrollView addSubview:bgViewName1];
    bgViewName1.backgroundColor = [UIColor whiteColor];
    
    
    UILabel *bankLabel = [[UILabel alloc] init];
    [bgViewName1 addSubview:bankLabel];
    bankLabel.text = @"银行";
    bankLabel.textColor = MC_SKYBLUE_COLOR;
    bankLabel.font = [UIFont systemFontOfSize:MC_REALVALUE(14)];
    
    MCButton *bankSelectedBtn = [[MCButton alloc] init];
    [bgViewName1 addSubview:bankSelectedBtn];
    [bankSelectedBtn addTarget:self action:@selector(bankSelectedBtnClick) forControlEvents:UIControlEventTouchDown];
    [bankSelectedBtn setTitle:@"请选择银行 >" forState:UIControlStateNormal];
    bankSelectedBtn.titleLabel.font = [UIFont systemFontOfSize:MC_REALVALUE(14)];
    [bankSelectedBtn setTitleColor:RGB(104, 104, 104) forState:UIControlStateNormal];
    
    UIView *bgViewName2 = [[UIView alloc] init];
    [baseScrollView addSubview:bgViewName2];
    bgViewName2.backgroundColor = [UIColor whiteColor];
    MCButton *shengSelectedBtn = [[MCButton alloc] init];
    [bgViewName2 addSubview:shengSelectedBtn];
    [shengSelectedBtn setTitle:@"请选择省份 >" forState:UIControlStateNormal];
    shengSelectedBtn.titleLabel.font = [UIFont systemFontOfSize:MC_REALVALUE(14)];
    [shengSelectedBtn addTarget:self action:@selector(shengSelectedBtnClick) forControlEvents:UIControlEventTouchDown];
    shengSelectedBtn.titleLabel.font = [UIFont systemFontOfSize:MC_REALVALUE(14)];
    [shengSelectedBtn setTitleColor:RGB(104, 104, 104) forState:UIControlStateNormal];
    
    UIView *lineView2 = [[UIView alloc] init];
    lineView2.backgroundColor = MC_SEPAETOR_COLOR;
    [baseScrollView addSubview:lineView2];
    MCButton *citySelectedBtn = [[MCButton alloc] init];
    [bgViewName2 addSubview:citySelectedBtn];
    [citySelectedBtn setTitle:@"请选择市区 >" forState:UIControlStateNormal];
    citySelectedBtn.titleLabel.font = [UIFont systemFontOfSize:MC_REALVALUE(14)];
    [citySelectedBtn addTarget:self action:@selector(citySelectedBtnClick) forControlEvents:UIControlEventTouchDown];
    citySelectedBtn.titleLabel.font = [UIFont systemFontOfSize:MC_REALVALUE(14)];
    [citySelectedBtn setTitleColor:RGB(104, 104, 104) forState:UIControlStateNormal];
    UIView *bgViewName4 = [[UIView alloc] init];
    [baseScrollView addSubview:bgViewName4];
    bgViewName4.backgroundColor = [UIColor whiteColor];
    UIView *bgViewName5 = [[UIView alloc] init];
    [baseScrollView addSubview:bgViewName5];
    bgViewName5.backgroundColor = [UIColor whiteColor];
    UITextField *bankNameTf = [[UITextField alloc] init];
    bankNameTf.attributedPlaceholder = [[NSAttributedString alloc] initWithString:@"请输入支行名称" attributes:@{NSForegroundColorAttributeName : [UIColor colorWithHexString:@"#b1b1b1"],NSFontAttributeName : [UIFont systemFontOfSize:MC_REALVALUE(14)]}];
    [bgViewName4 addSubview:bankNameTf];
    UITextField *cardNumTf = [[UITextField alloc] init];
    cardNumTf.attributedPlaceholder = [[NSAttributedString alloc] initWithString:@"请输入银行卡号" attributes:@{NSForegroundColorAttributeName : [UIColor colorWithHexString:@"#b1b1b1"],NSFontAttributeName : [UIFont systemFontOfSize:MC_REALVALUE(14)]}];
    [bgViewName5 addSubview:cardNumTf];
    nameLabel.backgroundColor = [UIColor whiteColor];
    UIView *lineView3 = [[UIView alloc] init];
    lineView3.backgroundColor = MC_SEPAETOR_COLOR;
    [baseScrollView addSubview:lineView3];

    UIButton *addBtn = [[UIButton alloc] init];
    [baseScrollView addSubview:addBtn];
    addBtn.backgroundColor = RGB(52, 154, 223);
    [addBtn setTitle:@"正确" forState:UIControlStateNormal];
    [addBtn addTarget:self action:@selector(addBtnClick) forControlEvents:UIControlEventTouchDown];
    baseScrollView.frame = CGRectMake(0, 0, G_SCREENWIDTH, G_SCREENHEIGHT - 64);

    [bgViewName mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.right.equalTo(self.baseScrollView);
        make.height.equalTo(@(44));
        make.width.equalTo(@(G_SCREENWIDTH));
    }];
    [nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(bgViewName).offset(MC_REALVALUE(10));
        make.top.equalTo(bgViewName);
        make.width.equalTo(@(50));
        make.height.equalTo(@(44));
        
    }];
    nameTf.backgroundColor = [UIColor whiteColor];
    [nameTf mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(nameLabel.mas_right).offset(MC_REALVALUE(20));
        make.centerY.equalTo(nameLabel);
        make.right.equalTo(bgViewName);
        make.height.equalTo(@(44));
    }];

    [lineView1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.equalTo(@(0.5));
        make.top.equalTo(nameTf.mas_bottom);
        make.left.right.equalTo(self.baseScrollView);
    }];
    [bgViewName1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.equalTo(self.baseScrollView);
        make.top.equalTo(lineView1.mas_bottom);
        make.height.equalTo(@(44));
        
    }];
    [bgViewName2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.equalTo(self.baseScrollView);
        make.top.equalTo(bgViewName1.mas_bottom).offset(MC_REALVALUE(10));
        make.height.equalTo(@(44));
        
    }];
    
    [bankLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(bgViewName1).offset(MC_REALVALUE(10));
        make.top.equalTo(bgViewName1);
        make.width.equalTo(@(50));
        make.height.equalTo(@(44));
        
    }];
    bankLabel.backgroundColor = [UIColor whiteColor];
    [bankSelectedBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(bankLabel.mas_right).offset(MC_REALVALUE(20));
        make.centerY.equalTo(bankLabel);
        make.right.equalTo(bgViewName1);
        make.height.equalTo(@(44));
    }];
    
    bankSelectedBtn.backgroundColor = [UIColor whiteColor];
    [shengSelectedBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(bankLabel);
        make.top.equalTo(bgViewName1.mas_bottom).offset(MC_REALVALUE(10));
        make.width.equalTo(@(G_SCREENWIDTH * 0.5 - MC_REALVALUE(20)));
        make.height.equalTo(@(44));
        
    }];
      shengSelectedBtn.backgroundColor = [UIColor whiteColor];
      citySelectedBtn.backgroundColor = [UIColor whiteColor];
    [lineView2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(shengSelectedBtn.mas_right);
        make.width.equalTo(@(0.5));
        make.top.bottom.equalTo(shengSelectedBtn);
    }];
   
    [citySelectedBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(lineView2.mas_right).offset(20);
        make.top.equalTo(bankSelectedBtn.mas_bottom).offset(MC_REALVALUE(10));
        make.width.equalTo(@(G_SCREENWIDTH * 0.5 - 0.5 - 20));
        make.height.equalTo(@(44));
    }];
    [bgViewName4 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.equalTo(self.baseScrollView);
        make.top.equalTo(shengSelectedBtn.mas_bottom).offset(MC_REALVALUE(10));
        make.height.equalTo(@(44));
    }];
    [bankNameTf mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(bankLabel);
        make.height.equalTo(@(44));
        make.right.top.equalTo(bgViewName4);
    }];
    bankNameTf.backgroundColor = [UIColor whiteColor];
    cardNumTf.backgroundColor = [UIColor whiteColor];
    
    [lineView3 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(bankNameTf.mas_bottom);
        make.left.right.equalTo(self.baseScrollView);
        make.height.equalTo(@(0.5));
    }];
    [bgViewName5 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.equalTo(self.baseScrollView);
        make.top.equalTo(bgViewName4.mas_bottom).offset(0.5);
        make.height.equalTo(@(44));
    }];
    [cardNumTf mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(bankLabel);
        make.height.equalTo(@(44));
        make.right.equalTo(self.baseScrollView);
        make.top.equalTo(bgViewName5);
    }];
   
    [addBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.baseScrollView).offset(MC_REALVALUE(10));
        make.right.equalTo(self.baseScrollView).offset(-MC_REALVALUE(10));
        make.height.equalTo(@(MC_REALVALUE(50)));
        make.top.equalTo(cardNumTf.mas_bottom).offset(MC_REALVALUE(30));
    }];
    addBtn.layer.cornerRadius = MC_REALVALUE(50) * 0.5;
    addBtn.clipsToBounds = YES;
    self.addBtn = addBtn;
    
}

- (void)bankSelectedBtnClick{
    
}

- (void)addBtnClick{
    [self.view endEditing:YES];
}
- (void)shengSelectedBtnClick{
    
}
- (void)citySelectedBtnClick{
    
}
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
    
}
- (void)dealloc{
    [[NSNotificationCenter defaultCenter] removeObserver:self];
}
@end
